package com.itshare.video.common.aop;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
 * @Author lyr
 * @create 2020/11/3 23:24
 */
public class AopPropertyUtils {
    /**
     * 基础数据类型
     * @param parameterType
     * @return
     */
    public static boolean isSimpleClazz(Class<?>parameterType) {
        if(parameterType.isPrimitive() ||
                BigDecimal.class.isAssignableFrom(parameterType)
                || BigInteger.class.isAssignableFrom(parameterType)) {
            return true;
        }

        return parameterType == String.class ||
                parameterType == Integer.class ||
                parameterType == Long.class ||
                parameterType == Double.class ||
                parameterType == Float.class ||
                parameterType == Byte.class ;


    }
    public static boolean isDate(Class type) {
        return type== Date.class;
    }

    /**
     * 判断是不是 java的 api
     * @param type
     * @return
     */
    public static boolean isJavaApi(Class type) {
        String name = type.getName();
        //java.lang, java.util, java.time
        return name.startsWith("java");
    }
    // public static void walkObject(Object value,Predicate<Field> condition, Consumer<Field>fieldConsumer) {
    //     if (value==null) return;
    //     for (Field field :value.getClass().getDeclaredFields()) {
    //         if(!field.isAccessible()) field.setAccessible(true);
    //
    //     }
    // }
    // public static void walkObject(Object object, Consumer<Object> callback) {
    //     if (object==null) {
    //         return;
    //     }
    //     callback.accept(object);
    // }
}
